home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan 2
/
Opus 5 - Magellan 2.iso
/
Extras
/
TwinOpus2
/
REXX
/
DOpus
/
ReadDir.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-10-13
|
3KB
|
130 lines
/*
*
* Get the contents of a directory from TwinExpres from DOpus.
*
* (c) 1994 by K.P. van Beem (2:280/464.2, patrick.van.beem@aobh.xs4all.nl)
*
* Based on the DOpusLhaARexx package by Geoff Seeley (but you can better
* use GuiArc in stead of DOpus and a script, to deal with archives)
*
*/
DOpusPort = 'DOPUS.1'
HandlerPort = 'TWIN.1'
userdata = ' 0' /* default */
fgpen = ' 1' /* palette 1 */
dirpen = ' 3' /* for directories */
bgpen = ' 0' /* palette 2 */
selectable = ' 1' /* can select */
unselectable = ' 0' /* can't select */
show = ' 0' /* update win */
before = ' -1' /* add to end */
if ~show(l,"rexxsupport.library") then
call addlib("rexxsupport.library",0,-30,0)
if showlist('Ports', DOpusPort) = 0 then do
say 'Directory Opus Arexx port not found. Aborting.'
call CleanUp
end
address 'DOPUS.1'
options results
/* Get some information from DOpus */
parse arg FilePath
if FilePath="" then do
TopText "You have to specify a directory."
exit
end
Status 3
CurrentWindow = Result
/* setup DOpus window and tell user what's happening */
ClearWin CurrentWindow
SetWinTitle FilePath
Busy on
TopText "Getting directory of CD, please wait..."
/* Address the list commando and a help to 'flush' the queue buffer
* never use a queue with a bigger buffer than the default buffer.
* The queue-handler doesn't flush automaticly!
*/
address command 'echo >PPipe: dir' FilePath
address command 'echo >PPipe: help'
/* parse the result from pipe: */
TopText "Parsing File(s). Please Wait..."
call ParseDir
'DisplayDir -1'
/* if handler is running, attach a custom handler to the window */
if show('p', HandlerPort) then
'AddCustHandler '||HandlerPort||' -1'
Busy off
call CleanUp
exit
/*---------------------------------------------------------------------------*/
ParseDir:
if open(PipeList, "QUEUE:Twin", 'R') then do
/* skip the header and the 'help-flush' from the last call... */
junk = ''
do while left(junk, 10, '') ~= "Listing of"
junk = readln(PipeList)
end
junk = readln(PipeList)
/* read files and dirs */
line = readln(PipeList)
do while length(line) ~= 0
/* do while left(line,4) ~= "TWIN" */
File = Quote(line)
if SubStr(line,26,9) = 'Directory' then
Entry = File || userdata || dirpen || bgpen || selectable || show || before
else
Entry = File || userdata || fgpen || bgpen || selectable || show || before
AddCustEntry Entry
line = readln(PipeList)
end
/* add invisible entry giving us the path and for recognition */
File = Quote('*'||FilePath)
Entry = File || userdata || bgpen || bgpen || unselectable || show || before
AddCustEntry Entry
close(PipeList)
end
else do
TopText "Can't open pipe:"
call CleanUp
end
return
/*---------------------------------------------------------------------------*/
CleanUp:
TopText "Ready"
Busy off
exit
return
/*---------------------------------------------------------------------------*/
Quote: procedure /* add quotes to string */
parse arg string
return '"'||string||'"'